<template>
  <div class=''>
    <!--  -->
    <Bootstrap v-bind:BootstrapTitle="BootstrapTitle"></Bootstrap>
    <el-card>
      <div id="main" style="width: 100%;height:400px;"></div>
    </el-card>
  </div>
</template>
<script>
import Bootstrap from "../../component/component/Bootstrap";
import echarts from "echarts";
import _ from "lodash";
export default {
  name: "",
  components: {
    Bootstrap,
  },
  data() {
    return {
      BootstrapTitle: {
        first: "数据统计",
        second: "/reports",
        third: " 数据报表",
      },
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },
  cerate() {},
  async mounted() {
    let res = await this.$http.get("reports/type/1");
    if (res.data.meta.status !== 200) {
      return this.$message.error(res.data.meta.msg);
    } else {
      this.$message.success(res.data.meta.msg);
    }
    console.log(res, "res");
    let echarts = require("echarts");
    var myChart = echarts.init(document.getElementById("main"));
    // 数据
    const result = _.merge(res.data.data, this.options);
    myChart.setOption(result);
  },
};
</script>

<style lang='less' scoped>
</style>